package com.hzj.service.impl;

import io.seata.spring.annotation.GlobalTransactional;

import com.hzj.pojo.User;
import com.hzj.mapper.UserMapper;
import com.hzj.service.MoneyFeignService;
import com.hzj.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author hzj
 * @since 2021-07-29
 */
@Service
@Transactional
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    UserMapper userMapper;
    @Autowired
    MoneyFeignService feignService;

    @Override
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    @GlobalTransactional
    public String edit() {
        System.out.println("进入user");
        User user = new User();
        user.setId(1);
        user.setMoney(10L);
        int editValue = userMapper.edit(user);
        int i = feignService.editMoney();
        int i1 = 1 / 0;
        return editValue + "|" + i;
    }
}
